package com.heima.article.controller;

import com.heima.article.service.ApArticleService;
import com.heima.model.article.dto.ArticleLoadDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.common.dtos.ResponseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @projectName: heima-leadnews
 * @package: com.heima.article.controller
 * @className: ArticleController
 * @author: Eric
 * @description: TODO
 * @date: 2023/11/4 9:45
 * @version: 1.0
 */
@RequestMapping("/api/v1/article")
@RestController
@RequiredArgsConstructor
public class ArticleController {

    private final ApArticleService apArticleService;

    @PostMapping("/load")
    public ResponseResult<List<ApArticle>> load(@RequestBody ArticleLoadDto articleLoadDto){
        List<ApArticle> articleList = apArticleService.load(articleLoadDto);
        return ResponseResult.okResult(articleList);
    }

    @PostMapping("/loadmore")
    public ResponseResult<List<ApArticle>> loadMore(@RequestBody ArticleLoadDto articleLoadDto){
        List<ApArticle> articleList = apArticleService.loadMore(articleLoadDto);
        return ResponseResult.okResult(articleList);
    }

    @PostMapping("//loadnew")
    public ResponseResult<List<ApArticle>> loadNew(@RequestBody ArticleLoadDto articleLoadDto){
        List<ApArticle> articleList = apArticleService.loadNew(articleLoadDto);
        return ResponseResult.okResult(articleList);
    }
}
